using System;
using UnityEngine;

public class DataManager : MonoBehaviour
{
	public static DataManager Instance;

	[SerializeField]
	private int initialFreeAdNumber = 10;

	[SerializeField]
	private int initialcheckads;

	[SerializeField]
	private int initialintads;

	[SerializeField]
	private int _freeadnum;

	[SerializeField]
	private int _checkforads;

	[SerializeField]
	private int _intads;

	[SerializeField]
	private int _missions;

	[SerializeField]
	private int _maps;

	[SerializeField]
	private int _vehicle;

	[SerializeField]
	private int _x2coins;

	public int FreeAdNumber
	{
		get
		{
			return _freeadnum;
		}
		private set
		{
			_freeadnum = value;
		}
	}

	public int intCheckForAds
	{
		get
		{
			return _checkforads;
		}
		private set
		{
			_checkforads = value;
		}
	}

	public int IntAds
	{
		get
		{
			return _intads;
		}
		private set
		{
			_intads = value;
		}
	}

	public int Missions
	{
		get
		{
			return _missions;
		}
		private set
		{
			_missions = value;
		}
	}

	public int Maps
	{
		get
		{
			return _maps;
		}
		private set
		{
			_maps = value;
		}
	}

	public int Vehicle
	{
		get
		{
			return _vehicle;
		}
		private set
		{
			_vehicle = value;
		}
	}

	public int X2Coins
	{
		get
		{
			return _x2coins;
		}
		private set
		{
			_x2coins = value;
		}
	}

	public static event Action<int> FreeAdNumberUpdated;

	public static event Action<int> intCheckForAdsUpdated;

	public static event Action<int> IntAdsUpdated;

	public static event Action<int> MissionsUpdated;

	public static event Action<int> MapsUpdated;

	public static event Action<int> VehicleUpdated;

	public static event Action<int> X2CoinsUpdated;

	private void Awake()
	{
		if ((bool)Instance)
		{
			UnityEngine.Object.DestroyImmediate(base.gameObject);
			return;
		}
		Instance = this;
		UnityEngine.Object.DontDestroyOnLoad(base.gameObject);
	}

	private void Start()
	{
		Reset();
	}

	public void Reset()
	{
		ResetFreeAds();
	}

	public void ResetFreeAds()
	{
		FreeAdNumber = PlayerPrefs.GetInt("FreeAdsNumber", initialFreeAdNumber);
		intCheckForAds = PlayerPrefs.GetInt("CheckForAds", initialcheckads);
		IntAds = PlayerPrefs.GetInt("IntAds", initialintads);
		Missions = PlayerPrefs.GetInt("Mis", _missions);
		Maps = PlayerPrefs.GetInt("Mapsown", _maps);
		Vehicle = PlayerPrefs.GetInt("Vehicleown", _vehicle);
		X2Coins = PlayerPrefs.GetInt("x2Coin", _x2coins);
	}

	public void AddMissions(int amount)
	{
		Missions += amount;
		PlayerPrefs.SetInt("Mis", Missions);
		DataManager.MissionsUpdated(Missions);
	}

	public void AddMaps(int amount)
	{
		Maps += amount;
		PlayerPrefs.SetInt("Mapsown", Maps);
		DataManager.MapsUpdated(Maps);
	}

	public void AddVehicle(int amount)
	{
		Vehicle += amount;
		PlayerPrefs.SetInt("Vehicleown", Vehicle);
		DataManager.VehicleUpdated(Vehicle);
	}

	public void AddX2Coins(int amount)
	{
		X2Coins += amount;
		PlayerPrefs.SetInt("x2Coin", X2Coins);
		DataManager.X2CoinsUpdated(X2Coins);
	}

	static DataManager()
	{
		DataManager.FreeAdNumberUpdated = delegate
		{
		};
		DataManager.intCheckForAdsUpdated = delegate
		{
		};
		DataManager.IntAdsUpdated = delegate
		{
		};
		DataManager.MissionsUpdated = delegate
		{
		};
		DataManager.MapsUpdated = delegate
		{
		};
		DataManager.VehicleUpdated = delegate
		{
		};
		DataManager.X2CoinsUpdated = delegate
		{
		};
	}
}
